# -*- codeing = utf-8 -*-
# @Time: 2023/6/10 11:10
# @Author: caoyi
# @File: goods_add_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By

from tests.pages.base_page import BasePage
from tests.pages.goods_page import GoodsListPage


class GoodsAddPage(BasePage):
    '''
    商品添加页面,集成父类BasePage用于复用driver
    '''
    def send_keys_goods_number(self,goods_number):
        # 输入商品编号
        goods_number_input = '.el-input__inner'
        # goods_number = int(goods_number)
        self.driver.find_element(By.CSS_SELECTOR, goods_number_input).send_keys(goods_number)

    def send_keys_goods_name(self,goods_name):
        # 输入商品名称
        goods_name_input = '//*[text()="商品名称"]/../div/div/input'
        # goods_name = f"{self.PREFIX_NUM}_{str(self.nowtime)}_商品名称添加"
        self.driver.find_element(By.XPATH, goods_name_input).send_keys(goods_name)

    def click_putaway_button(self):
        #         上架
        putaway_button = '//*[text()="上架"]'
        self.driver.find_element(By.XPATH, putaway_button).click()
        # 跳转到商品列表页面
        return GoodsListPage(self.driver)